<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.augmentum.login.Constants"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="com.augmentum.login.model.Question"%>
<%@ page import="com.augmentum.login.util.Prop"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String basePath = request.getContextPath();
   String staticPath = Prop.get(Constants.STATIC_PATH);
   List list = (List) request.getAttribute(Constants.QUESTION_LIST);
%>
<script type="text/javascript">
    $(document).ready(function(){
        $("input[name='selectedId']").click(function() {
            if(!this.checked) {
                $("#questionIds").attr("checked" ,false);
            }
        });
    });
</script>
<div id="bottomId" class="common border-style">
  <div class="float-left" style="width:20%">
    <div class="common common-width float-left">
      <div class="common common-width">
        <span class="layout-center style-span"></span>
      </div>
      <div class="common common-width">
        <span onclick="getClick('<%=basePath%>/page/question/search')"
          class="cursor bg-color01 color-style03 font-style03 color-style01 layout-center style-span">QuestionList</span>
      </div>
      <div class="common common-width">
        <span onclick="getClick('<%=basePath%>/page/question/createPage')"
          class="cursor font-style03 color-style01 layout-center style-span">Create Question</span>
        <hr class="hr-style color-style01" />
      </div>
    </div>
  </div>
  <hr class="float-left common-height" style="widht:1%;color:#9D9D9D" />
  <div id="iframeId" style="width:79%;" class="common common-height float-left">
    <div class="common">
      <div style="width: 100%;" class="common common-height float-left">
        <div class="layout-div" style="height:42px;">
          <div id="questionId" class="font-style03 float-right Div-style" style="height:27px;margin-top:10px;margin-bottom:5px">
            <form id="form01" class="common-length" name="form01" action="<%=basePath%>/page/question/search" method="post">
              <input id="question_id" name="description" type="text" class="float-left common common-height" placeholder="Please input keyword" />
              <img style="cursor:pointer" alt="search" onclick="javascript:document.form01.submit();" class="common float-left" src="<%=staticPath%>/images/ICN_Search_15x20.png" />
            </form>
          </div>
        </div>
        <div class="layout-div radius5" style="border:1px #2E4358 solid">
          <div class="common common-width common-height">
            <div class="header color-style04 font-style03 common-width" style="height: 25px; padding: 10px;">
              <div class="head-width common float-left layout-center">ID
                <img id="orderId" style="cursor:pointer" onclick="javascript:document.form02.submit();" alt="increate" src="<%=staticPath%>/images/ICN_Increase_10x15.png" />
                <form class="common" name="form02" action="<%=basePath%>/page/question/search" method="post">
                  <input type="hidden" name="description" value="<%=request.getAttribute("description")%>" />
                  <input id="orderValueId" type="hidden" name="question_id" value="question_id ASC" />
                </form>
              </div>
              <div class="common float-left layout-center" style="width: 50%;">Description</div>
              <div class="head-width common float-left layout-center">
                Edit&nbsp;&nbsp;&nbsp;
                <span>
                  <input id="questionIds" style="cursor:pointer" onclick="selectedAll(this, 'selectedId')" type="checkbox" name="questionIds" />
                </span>
              </div>
            </div>
            <hr style="border:1px #2E4358 solid;margin:0px;padding:0" class="common-width" />
            <div class="content-list common-width float-left radius5" style="border:1px #2E4358 solid">
              <%
                  int num = 1;
                  if (list.size() > 0) {
                      List<Question> questions = list;
                      Question q = null;
                      for (Question o : questions) {
                          q = o;
              %>
              <div class="layout-center common common-width float-left" style="border-bottom:1px #2E4358 solid;">
                <span class="float-left common common-height" style="width:10%;height:20px;color:#0A0A0A;overflow:hidden"><%=num++%></span>
                <span class=" float-left color-style04 common common-height font-style06" style="width:10%;height:20px;overflow:hidden" ><%=q.getQuestionId()%></span>
                <span class=" float-left color-style05 common common-height font-style06 float-left zxx_text_overflow" style="width:60%;height:20px;overflow:hidden"><%=q.getDescription()%></span>
                <span class="float-left common common-height" style="width:10%;height:20px;overflow:hidden" >&nbsp;&nbsp;&nbsp;
                  <img onclick="edit('<%=basePath%>/page/question/editPage','id=<%=q.getQuestionId()%>');" src="<%=staticPath%>/images/ICN_Edit_15x15.png.png" /></span>
                <span class="float-left common common-height" style="width:10%;height:20px;overflow:hidden">
                  <input style="cursor:pointer" class="float-left" value="<%=q.getId()%>" type="checkBox" id="selectedId" name="selectedId" />
                </span>
              </div>
              <%
                     }
                  }
              %>
            </div>
          </div>
          <div style="clean: both"></div>
          <jsp:include page="../../jsp/page.jsp" />
        </div>
      </div>
    </div>
  </div>
  
  <script type="text/javascript">
      <%-- var optionArray = document.getElementById("orderId").options;
      for(var i = 0; i < optionArray.length; i++) {
          var b = optionArray[i].value == '<%= request.getAttribute("order")%>';
          if(b) {
              optionArray[i].selected = 'selected';
          }
      } --%>
      $("#bottomId").height($("body").height()-$("#topId").height());
  </script>
  <div style="clean:both"></div>
</div>